package com.dhl.commonutils.exception;

import com.dhl.commonutils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 * @title: GlobalExceptionHandler
 * @Author danghailiang
 * @Date: 2022/10/14 22:54
 * @Version 1.0
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler extends RuntimeException {


    @ExceptionHandler(RuntimeException.class)
    public R ExceptionHandler (RuntimeException e){
        log.error("运行时全局异常捕获",e.getMessage());
        return R.error(e.getMessage());
    }
}
